create or replace type body m4o_buffer as

  -- ===========================================================================
  constructor function m4o_buffer(
    i_subst_start_tag in varchar2 := '{',
    i_subst_end_tag   in varchar2 := '}')
  return self as result
  is
  begin
    self.m_handle := m4o_buffer_impl.create_handle(
                       i_subst_start_tag => i_subst_start_tag,
                       i_subst_end_tag   => i_subst_end_tag);
    return;
  end;

  -- ===========================================================================
  member procedure free(self in out nocopy m4o_buffer)
  is
  begin
    m4o_buffer_impl.free_handle(self.m_handle);
    self.m_handle := -1;
  end;

  -- ===========================================================================
  member procedure clear
  is
  begin
    m4o_buffer_impl.clear_buffer(self.m_handle);
  end;
  -- ===========================================================================
  member procedure p(
    i_str in varchar2,
    i_fmt in boolean := true)
  is
  begin
    m4o_buffer_impl.p(
      i_handle => self.m_handle,
      i_str    => i_str,
      i_fmt    => i_fmt);
  end;

  -- ===========================================================================
  member procedure set_subst(
    i_key   in varchar2,
    i_value in varchar2)
  is
  begin
    m4o_buffer_impl.set_subst(
      i_handle => self.m_handle,
      i_key    => i_key,
      i_value  => i_value);
  end;
  -- ===========================================================================
  member function fmt(i_str in varchar2) return varchar2
  is
  begin
    return m4o_buffer_impl.fmt(
      i_handle => self.m_handle,
      i_str    => i_str);
  end;
  -- ===========================================================================
  member function get_str return varchar2
  is
  begin
    return m4o_buffer_impl.get_str(self.m_handle);
  end;
end;
/

